﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Mukhopatro.BusinessEntities;
using Mukhopatro.Helpers;

namespace Mukhopatro.BusinessLogicLayer
{
    public partial class CustomerContentBLL
    {
        public CustomerContent GetCustomerContent(string displayContentType, int clientId)
        {
            return (_socialShareDatabaseContext.CustomerContents.FirstOrDefault(customerContent => customerContent.CmsType.Equals(displayContentType) && customerContent.ClientId==clientId));
        }

        public Int32 GetContentsTotalCount(Func<CustomerContent, bool> query)
        {
            try
            {
                //initialization
                return _socialShareDatabaseContext.CustomerContents.Where(query).ToList().Count;
            }
            //handling other exceptions...
            catch (Exception ex)
            {
                //Error handling
                throw ex;
            }
        }

        public List<CustomerContent> GetContents(Func<CustomerContent, bool> query, string orderBy, int startRowIndex = default(int), int maximumRows = default(int))
        {
            try
            {
                //CustomerContent
                List<CustomerContent> result = _socialShareDatabaseContext.CustomerContents.Where(query).Skip(startRowIndex).Take(maximumRows).ToList();
                return result;
            }
            //handling other exceptions...
            catch (Exception ex)
            {
                //Error handling
                throw ex;
            }
        }

        public List<CustomerContent> GetContents(Func<CustomerContent, bool> query)
        {
            try
            {
                //CustomerContent
                List<CustomerContent> result = _socialShareDatabaseContext.CustomerContents.Where(query).ToList();
                return result;
            }
            //handling other exceptions...
            catch (Exception ex)
            {
                //Error handling
                throw ex;
            }
        }


    }
}